<?php

namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class SmsTemplate extends Base
{

    use SoftDelete;

    

    // 表名
    protected $name = 'sms_template';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'sms_type_text',
        'is_merge_text'
    ];
    

    
    public function getSmsTypeList()
    {
        return ['1' => __('Sms_type 1'), '2' => __('Sms_type 2'), '3' => __('Sms_type 3')];
    }

    public function getIsMergeList()
    {
        return ['0' => __('Is_merge 0'), '1' => __('Is_merge 1')];
    }


    public function getSmsTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sms_type']) ? $data['sms_type'] : '');
        $list = $this->getSmsTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsMergeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_merge']) ? $data['is_merge'] : '');
        $list = $this->getIsMergeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
